package com.yyb.service.impl;

import com.github.pagehelper.Page;
import com.yyb.common.PageInfo;
import com.yyb.domain.SysOperLog;
import com.yyb.dto.SysOperLogQueryDTO;
import com.yyb.mapper.SysOperLogMapper;
import com.yyb.service.SysOperLogService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 描述: [操作日志的业类]
 * 
 * 
 */
@Service
public class SysOperLogServiceImpl extends BaseServiceImpl<SysOperLog> implements SysOperLogService {

    @Resource
    private SysOperLogMapper sysOperLogMapper;

    /**
     * 保存操作日志
     *
     * @param sysOperLog
     * @return
     */
    @Override
    public int insertSelective(SysOperLog sysOperLog) {
        return this.sysOperLogMapper.insertSelective(sysOperLog);
    }

    /**
     * 分页查询操作日志
     *
     * @param pageInfo
     * @return
     */
    @Override
    public PageInfo<SysOperLog, SysOperLogQueryDTO> getByPage(PageInfo<SysOperLog, SysOperLogQueryDTO> pageInfo) {
        Page<SysOperLog> startPage = this.startPage(pageInfo.getPageNumber(), pageInfo.getPageSize());

        List<SysOperLog> operLogList=this.sysOperLogMapper.queryAllOperLog(pageInfo.getParams());
        pageInfo.setTotalPage(startPage.getPages());
        pageInfo.setTotalCount(startPage.getTotal());
        pageInfo.setList(operLogList);
        return pageInfo;
    }

    /**
     * 根据ID删除操作日志
     *
     * @param operId
     * @return
     */
    @Override
    public int deleteByPrimaryKey(Long operId) {
        return this.sysOperLogMapper.deleteByPrimaryKey(operId);
    }

    /**
     * 批量删除操作日志
     *
     * @param operIds
     * @return
     */
    @Override
    public int deleteByPrimaryKeys(Long[] operIds) {
        if(operIds!=null&&operIds.length>0){
            return this.sysOperLogMapper.deleteByPrimaryKeys(operIds);
        }
        return 0;
    }

    /**
     * 清空操作日志
     *
     * @return
     */
    @Override
    public int deleteAllOperLog() {
        return this.sysOperLogMapper.deleteAllOperLog();
    }
}
